#include <algorithm>
#include <cmath>
#include <stdexcept>

using namespace std;

class Shape {
  public:
    virtual ~Shape();
    virtual double GetPerimeter() = 0;
};

class Rectangle : public Shape {
  public:
    Rectangle(double a, double b);
    virtual double GetPerimeter() override;

  private:
    double length;
    double width;
};

class Circle : public Shape {
  public:
    Circle(double r);
    virtual double GetPerimeter() override;

  private:
    double radius;
};

Rectangle::Rectangle(double a, double b) {
    length = max(a, b);
    width = min(a, b);
}

double Rectangle::GetPerimeter() { return 2 * (length + width); }

Circle::Circle(double r) : radius(r) {}

double Circle::GetPerimeter() { return M_PI * radius; }
